import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '模板名称',
    dataIndex: 'templateName',
    align: 'center',
  },
  {
    title: '投入品名称',
    align:"center",
    dataIndex: 'name'
  },

  {
    title: '俗称',
    align:"center",
    dataIndex: 'popularName'
  },
  {
    title: '投入品种类',
    align:"center",
    dataIndex: 'input_dictText'
  },
  {
    title: '特征描述',
    align:"center",
    dataIndex: 'feature'
  },
  {
    title: '生产厂家',
    align:"center",
    dataIndex: 'manufacturer'
  },
  {
    title: '出厂日期',
    align:"center",
    dataIndex: 'productionDate',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text)
    },
  },
  {
    title: '保质期',
    align:"center",
    dataIndex: 'qualityPeriod'
  },
  {
    title: '库存量(kg)',
    align:"center",
    dataIndex: 'stock'
  },
  {
    title: '最低库存量(kg)',
    align:"center",
    dataIndex: 'stockLowest'
  },
  {
    title: '最高库存量(kg)',
    align:"center",
    dataIndex: 'stockHighest'
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "模板名称",
    field: 'templateName',
    component: 'Input',
    colProps: {span: 6},
  },
  {
    label: "投入品名称",
    field: 'name',
    component: 'Input',
    colProps: {span: 6},
  },
  {
    label: "投入品种类",
    field: 'input',
    component: 'JTreeSelect',
    componentProps: {
      dict: "t_classification,name,id",
      pidField: "pid",
      pidValue: "1690898175602962434",
      hasChildField: "has_child",
    },
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '模板名称',
    field: 'templateName',
    component: 'Input',
  },
  {
    label: '投入品名称',
    field: 'name',
    component: 'Input'
  },
  {
    label: '投入品编号',
    field: 'no',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入投入品编号!'},
      ];
    },
  },
  {
    label: '俗称',
    field: 'popularName',
    component: 'Input'
  },
  {
    label: '投入品种类',
    field: 'input',
    component: 'JTreeSelect',
    componentProps: {
      dict: "t_classification,name,id",
      pidField: "pid",
      pidValue: "1690898175602962434",
      hasChildField: "has_child",
      placeholder: '请选择投入品种类',

    },
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请选择投入品种类!'},
      ];
    },
  },
  {
    label: '特征描述',
    field: 'feature',
    component: 'Input',
  },
  {
    label: '生产厂家',
    field: 'manufacturer',
    component: 'Input',
  },
  {
    label: '出厂日期',
    field: 'productionDate',
    component: 'DatePicker',
  },
  {
    label: '保质期',
    field: 'qualityPeriod',
    component: 'Input',
  },
  {
    label: '库存量(kg)',
    field: 'stock',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入库存量!'},
      ];
    },
  },
  {
    label: '最低库存量(kg)',
    field: 'stockLowest',
    component: 'InputNumber',
  },
  {
    label: '最高库存量(kg)',
    field: 'stockHighest',
    component: 'InputNumber',
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false
  },
];



/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
